<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>会员管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../css/common.css" media="all">
	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-tab layui-tab-brief" lay-filter="changetab">
							<ul class="layui-tab-title" id="view_ul"></ul>

							<div class="layui-card-body">
								<!--<div class="layui-card-header"> 会员信息
								 <button class="layui-btn layui-btn-normal layui-btn-sm" data-type='add' id="add">添加</button> 
								 <button class="layui-btn layui-btn-default layui-btn-sm" id="del">划拨</button> 
							</div>-->
								<!-- 搜索 -->
								<form class="layui-form search" id="form" onsubmit="return false" action="##">
									<div class="layui-inline search_inline">
										<label class="layui-form-label">发起人：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="" placeholder="发起人" name="member_id" id="member_id" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">收款人：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="" placeholder="收款人" name="to_memberid" id="to_memberid" autocomplete="off">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">姓名/手机号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="keyword" placeholder="姓名、手机号" name="keyword" autocomplete="off">
										</div>
									</div>

									<button class="layui-btn search_inline" lay-submit="" lay-filter="search" data-type="reload">搜索</button>
									<button class="layui-btn layui-btn-primary search_inline" type="reset">重置</button>
								</form>
								<!-- 搜索 -->

								<table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
								<script type="text/html" id="test-table-operate-barDemo">
									<button class="layui-btn layui-btn-default layui-btn-sm" lay-event="">修改</button>
								</script>
							</div>
						</div>
					</div>
				</div>
			</div>

		</div>
		</div>
		<script type="text/html" id="demo_ul">
			<li class="layui-this" lay-id=''>全部</li>
			{{# layui.each(d, function(index, item){ }}
			<li class="" lay-id='{{ item.accountid }}'>{{ item.accountname }}</li>
			{{# }); }}
		</script>
		<script src="../../layuiadmin/layui/layui.js"></script>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/common.js"></script>
		<script>
			var _data = {
				parent_id: getParam('id'),
				accountid:''
			}
			
			
				
				
			layui.config({
				base: '../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'table', 'form', 'treeGrid', 'laytpl','element'], function() {
				var table = layui.table,
					$ = layui.$,
					form = layui.form,
					laydate = layui.laydate,
					treeGrid = layui.treeGrid,
					laytpl = layui.laytpl,
					element= layui.element,
					admin = layui.admin;

				console.log(_data)

				card_type()
				initdata();
				
				
				
				element.on('tab(changetab)', function(elem) {
					accountid = this.getAttribute('lay-id');
					_data.accountid = accountid;
					initdata();
				});
				function initdata() {
					loading()
					table.render({
						elem: '#test-table-operate',
						url: server.transfer_record_query,
						height: 'full-115',
						cellMinWidth: cellMinWidth,
						limit: limit,
						limits: limits,
						cols: [
							[{
								width: 70,
								type: 'numbers',
								title: '序号',
								fixed: 'left',
							},{
								width: 180,
								field: 'id',
								title: '编号'
							},
//							{
//								type: 'checkbox',
//								fixed: 'left'
//							}, 
//							{
//								width: 170,
//								align: 'center',
//								fixed: 'right',
//								toolbar: '#test-table-operate-barDemo',
//								title: '操作',
//								fixed: 'left'
//							}, 
							{
								field: 'memberid',
								title: '发起人', 
							}, {
								field: 'name',
								title: '发起人姓名', 
							},  {
								field: 'mobile',
								width: 180,
								title: '发起人手机号码'
							},{
								field: 'to_memberid',
								title: '收款人', 
							}, {
								field: 'amount',
								title: '金额', 
							}, {
								field: 'to_name',
								title: '收款人姓名', 
							},   {
								field: 'to_mobile',
								width: 180,
								title: '收款人手机号码'
							},{
								field: 'add_by',
								title: '创建人',
							}, {
								field: 'addtime',
								title: '创建时间',
							}, {
								field: 'edit_by',
								title: '更新人',
							}, {
								field: 'edittime',
								title: '更新时间',
							}]
						],
						page: true,
						where: _data,
						request: {
							pageName: 'page',
							limitName: 'size',
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
							
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.transfer_record.pager.total, //解析数据长度
								"data": res.transfer_record.data //解析数据列表
							};
						},
						done:function(){
							closeloading()
						}
					});
				}

				$('#add').on('click', function() {
					layer.open({
						type: 2,
						title: '添加',
						shadeClose: true,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['750px', '700px'],
						content: 'model/edit_add.html?customerid=' + $("#customerid").val(),
						end: function() {

						}
					});
				});

				//监听搜索
				form.verify({
					memberid: function(value, item) { //value：表单的值、item：表单的DOM对象
						if(!value) {
							return '姓名不能为空';
						}
					}
				});

				//监听搜索
				form.on('submit(search)', function(data) {
					_data = data.field
					initdata();
					return false;
				});

				$("button[type=reset]").on("click", function() {
					_data = {}
					initdata();
					document.getElementById("form").reset();
				});

				//监听表格复选框选择
				table.on('checkbox(test-table-operate)', function(obj) {
					console.log(obj)
				});

				//监听工具条
				table.on('tool(test-table-operate)', function(obj) {
					var data = obj.data;
					if(obj.event === 'edit') {
						layer.open({
							type: 2,
							title: '修改',
							shadeClose: true,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['750px', '700px'],
							content: ' ?id=' + data.id,
							end: function() {

							}
						});
					} else if(obj.event === 'dredge') {
						 
					} else if(obj.event === 'transfer') {
						layer.open({
							type: 2,
							title: '划拨',
							shadeClose: true,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['750px', '700px'],
							content: ' ?id=' + data.id,
							end: function() {

							}
						});
					}
				});

				var $ = layui.$,
					active = {
						getCheckData: function() { //获取选中数据
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.alert(JSON.stringify(data));
						},
						getCheckLength: function() { //获取选中数目
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.msg('选中了：' + data.length + ' 个');
						},
						isAll: function() { //验证是否全选
							var checkStatus = table.checkStatus('test-table-operate');
							layer.msg(checkStatus.isAll ? '全选' : '未全选')
						}
					};

				$('.test-table-operate-btn .layui-btn').on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});  
				
				function card_type() {
					loading() 
					$.ajax({
						type: "get",
						url: server.transfer_record_query,
						async: false,
						success: function(res) {
							if(res.code == 0) {
								var data = res.account.data;
								var getTpl = demo_ul.innerHTML,
									view = document.getElementById('view_ul');
								laytpl(getTpl).render(data, function(html) {
									view.innerHTML = html;
									console.log(html)
								});

							} else {
								layer.msg(res.msg);
							}
						}
					});

					closeloading();
				}
			});
		</script>
	</body>

</html>